package com.hobbit.utils
{
	import com.emibap.textureAtlas.DynamicAtlas;
	
	import flash.display.BitmapData;
	
	import starling.display.MovieClip;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;

	/**
	 * 转换类 
	 * @author 晓晔
	 * 
	 */
	public class Convert
	{
		/**
		 * 通过CLASS生成starling的movieclip --->支持自己拼接
		 * @param $classVector:Vector.<Class> assetsManager里得来的class
		 * @param $fps fps
		 * @return 用于starling的mc
		 * 
		 */
		public static function convert2StarlingMovieClip($classVector:Vector.<Class>,$fps:Number = 12):MovieClip
		{
			var mc:MovieClip = new MovieClip(getTextureAtlas($classVector).getTextures(),$fps);
			return mc;
		}
		
		/**
		 * 获取TextureAtlas
		 * @param $classVector:Vector.<Class> assetsManager里得来的class
		 * @return 
		 * 
		 */
		public static function getTextureAtlas($classVector:Vector.<Class>):TextureAtlas
		{
			return DynamicAtlas.fromClassVector($classVector);
		}
		
		/**
		 * 把class（图片类）
		 * @param $class
		 */
		public static function getTexture($class:Class):Texture
		{
			return Texture.fromBitmapData(new $class as BitmapData);
		}
	}
}